package com.demo.modules.job.common.service;

import com.demo.common.core.result.R;
import com.xxl.job.core.context.XxlJobContext;
import com.xxl.job.core.handler.annotation.XxlJob;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

/**
 * @author MyPC
 */
@Slf4j
@Component
public class XxlJobScheduled {
    @XxlJob("xxlJobTask")
    public R<String> xxlJobTest(String date) {
        XxlJobContext xxlJobContext = XxlJobContext.getXxlJobContext();
        String jobParam = xxlJobContext.getJobParam();
        try {
            //模拟业务处理线程休眠2秒
            Thread.sleep(2000L);
        } catch (Exception e) {
            e.printStackTrace();
        }
        log.info("xxlJobTest定时任务执行成功,jobParam:{}", jobParam);
        return R.ok();
    }
}

